export const state = () => ({
    posts: []
})
export const mutations = {
    addPosts(state, data) {
        // console.log(data);
        // 检查历史记录是否有重复的标题
        let existed = false;
        state.posts.forEach(ele => {
            if (ele.title == data.title &&
                ele.content == data.content &&
                ele.city == data.city) {
                existed = true
            }
        })
        if (!existed) {
            state.posts.push(data)
        }

    },
    deletePosts(state, data) {
        state.posts.splice(data.index, 1)
    }
}
export const actions = {}